<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>个人资料 - {{ current_user.nickname }}</title>
    <!-- Bootstrap 5 CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <style>
        .profile-header {
            background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
            color: white;
            border-radius: 15px;
            box-shadow: 0 5px 15px rgba(0,0,0,0.1);
        }
        .avatar-container {
            width: 180px;
            height: 180px;
            border: 5px solid rgba(255,255,255,0.3);
            border-radius: 50%;
            overflow: hidden;
            margin: -90px auto 20px;
            background: white;
        }
        .profile-avatar {
            width: 100%;
            height: 100%;
            object-fit: cover;       /* 裁剪填充 */
            object-position: center; /* 居中显示 */
            background-color: #f8f9fa;
        }
        .avatar-img { /* 兼容旧类名 */
            @extend.profile-avatar; 
        }
        .info-card {
            border-radius: 12px;
            box-shadow: 0 3px 10px rgba(0,0,0,0.08);
            transition: transform 0.3s;
        }
        .info-card:hover {
            transform: translateY(-5px);
        }
        .edit-btn {
            position: absolute;
            top: 20px;
            right: 20px;
        }
    </style>
</head>
<body>
    <div class="container py-5">
        <div class="row justify-content-center">
            <div class="col-lg-8">
                <!-- 资料头部区域 -->
                <div class="profile-header text-center p-4 position-relative">
                    <div class="avatar-container">
                        <img 
                          {% if current_user.avatar %}
                          src="{{ url_for('web.media_images', filename=current_user.avatar)}}?v={{ current_user.update_time|default(now, true) }}" 
                          {% else %}
                          src="{{ url_for('web.media_images', filename='default.png') }}"
                          {% endif %}
                          alt="用户头像"
                          class="profile-avatar" <!-- 确保应用已定义的类 -->
                          style="width:100%; height:100%; object-fit:cover; object-position:center" <!-- 关键样式 -->
                        >
                    </div>
                    <a href="{{ url_for('web.edit_profile') }}" class="btn btn-light edit-btn">
                        <i class="fas fa-edit"></i> 编辑资料
                    </a>
                </div>
                
                <!-- 资料详情卡片 -->
                <div class="card info-card mt-4">
                    <div class="card-body">
                        <h1 class="text-center mb-4">{{ current_user.nickname }}的个人资料</h1>
                        
                        <div class="row">
                            <!-- 左侧基本信息 -->
                            <div class="col-md-6">
                                <div class="mb-4">
                                    <h5><i class="fas fa-user me-2"></i> 基本信息</h5>
                                    <hr>
                                    <p><strong>性别：</strong> 
                                        {% if current_user.gender == 'male' %}男{% else %}女{% endif %}
                                    </p>
                                    <p><strong>国家/地区：</strong> {{ current_user.country }}</p>
                                    <p><strong>电子邮箱：</strong> {{ current_user.email or 'Empty'}}</p>
                                </div>
                            </div>
                            
                            <!-- 右侧统计信息 -->
                            <div class="col-md-6">
                                <div class="mb-4">
                                    <h5><i class="fas fa-chart-line me-2"></i> 账户统计</h5>
                                    <hr>
                                    <p><strong>注册时间：</strong> {{ current_user.created_at.strftime('%Y-%m-%d') }}</p>
            
                                </div>
                            </div>
                        </div>
                        
                        <!-- 简介区域 -->
                        <div class="mt-4">
                            <h5><i class="fas fa-address-card me-2"></i> 个人简介</h5>
                            <hr>
                            {% if current_user.bro %}
                                <p class="lead">{{ current_user.bro }}</p>
                            {% else %}
                                <div class="alert alert-info">
                                    您还没有填写个人简介，<a href="{{ url_for('web.edit_profile') }}">点击添加</a>
                                </div>
                            {% endif %}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    <!-- Bootstrap & Font Awesome -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/js/all.min.js"></script>
</body>
</html>